<?php

	/*
	 * AJAX call to load the basic statistics.
	 *
	 * Variables:
	 *  none
	 *
	 * Returns:
	 *  html code
	 *
	 */

	header('Content-type: text/plain');
	$lastd = preg_replace("/\D/","",$settings["party_date"]." ".$settings["party_hour"].":00");


	$sql = mysql_query("SELECT * FROM filterwords ORDER BY fwText", $db);
	$filters_words = array();
	while($row = mysql_fetch_array($sql, MYSQL_ASSOC)){
		array_push($filters_words, $row["fwText"]);
	}

	$sql = mysql_query("SELECT * FROM filternumbers ORDER BY fnNR", $db);
	$filters_numers = array();
	while($row = mysql_fetch_array($sql, MYSQL_ASSOC)){
		array_push($filters_numers, $row["fnNR"]);
		array_push($filters_numers, "+".$row["fnNR"]);
	}

	$smssql = mysql_query("SELECT * FROM inbox WHERE UpdatedInDB > $lastd");
	$temp = mysql_num_rows($smssql);
	$smssql = mysql_query("SELECT * FROM inbox WHERE UpdatedInDB > $lastd ".($settings["ban_by_number"]?" AND SenderNumber NOT IN (\"".implode("\",\"", $filters_numers)."\") ":"").($settings["ban_by_content"]?" AND TextDecoded NOT LIKE \"%".implode("%\" AND TextDecoded NOT LIKE \"%", $filters_words)."%\"":""));

	echo '
	Number of running SMS messages: '.mysql_num_rows($smssql).'<br />
	Number of SMS messages in total: '.$temp.'<br />
	Number of banned SMS messages: '.($temp - mysql_num_rows($smssql)).'
	';

?>